<html>
<head>
	<title>Tests for JU.validate</title>
	
	<script type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
	<script type="text/javascript" src="../src/janutils.js"></script>
	<script type="text/javascript" src="../src/string.js"></script>
	
	<script type="text/javascript">
	
	//--------------------------------------------------------------------------
	// Tests with null parameters
	//--------------------------------------------------------------------------
	
	/*
	 * Tests isEmpty() with a null parameter
	 */
	function testIsEmptyWithNull() {
		assertTrue(JU.string.isEmpty(null));
	}
	
	/*
	 * Tests isBlank() with a null parameter
	 */
	function testIsBlankWithNull() {
		assertTrue(JU.string.isBlank(null));
	}
	
	/*
	 * Tests isDigits() with a null parameter
	 */
	function testIsDigitsWithNull() {
		assertFalse(JU.string.isDigits(null));
	}
	
	/*
	 * Tests isInteger() with a null parameter
	 */
	function testIsIntegerWithNull() {
		assertFalse(JU.string.isInteger(null));
	}
	
	/*
	 * Tests isDecimal() with a null parameter
	 */
	function testIsDecimalWithNull() {
		assertFalse(JU.string.isDecimal(null));
	}
	
	/*
	 * Tests isDate() with null parameters
	 */
	function testIsDateWithNull() {
		assertFalse(JU.string.isDate(null, null));
	}
	
	/*
	 * Tests isDate() with a null date and a valid format
	 */
	function testIsDateWithDateNull() {
		assertFalse(JU.string.isDate(null, 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a valid date and a null format
	 */
	function testIsDateWithFormatNull() {
		assertFalse(JU.string.isDate('20/03/1982', null));
	}
	
	/*
	 * Tests isEmail() with a null parameter
	 */
	function testIsEmailWithNull() {
		assertFalse(JU.string.isEmail(null));
	}
	
	/*
	 * Tests trim() with a null parameter
	 */
	function testTrimWithNull() {
		assertEquals('', JU.string.trim(null));
	}
	
	//--------------------------------------------------------------------------
	// Tests with undefined parameters
	//--------------------------------------------------------------------------
	
	/*
	 * Tests isEmpty() with an undefined parameter
	 */
	function testIsEmptyWithUndefined() {
		assertTrue(JU.string.isEmpty(undefined));
	}
	
	/*
	 * Tests isBlank() with an undefined parameter
	 */
	function testIsBlankWithUndefined() {
		assertTrue(JU.string.isBlank(undefined));
	}
	
	/*
	 * Tests isDigits() with an undefined parameter
	 */
	function testIsDigitsWithUndefined() {
		assertFalse(JU.string.isDigits(undefined));
	}
	
	/*
	 * Tests isInteger() with an undefined parameter
	 */
	function testIsIntegerWithUndefined() {
		assertFalse(JU.string.isInteger(undefined));
	}
	
	/*
	 * Tests isDecimal() with an undefined parameter
	 */
	function testIsDecimalWithUndefined() {
		assertFalse(JU.string.isDecimal(undefined));
	}
	
	/*
	 * Tests isDate() with an undefined parameter
	 */
	function testIsDecimalWithUndefined() {
		assertFalse(JU.string.isDate(null, null));
	}
	
	/*
	 * Tests isEmail() with an undefined parameter
	 */
	function testIsEmailWithUndefined() {
		assertFalse(JU.string.isEmail(undefined));
	}
	
	/*
	 * Tests trim() with an undefined parameter
	 */
	function testTrimWithUndefined() {
		assertEquals('', JU.string.trim(undefined));
	}
	
	//--------------------------------------------------------------------------
	// Tests with empty parameters
	//--------------------------------------------------------------------------
	
	/*
	 * Tests isEmpty() with an empty string parameter
	 */
	function testIsEmptyWithEmptyString() {
		assertTrue(JU.string.isEmpty(''));
	}
	
	/*
	 * Tests isBlank() with an empty string parameter
	 */
	function testIsBlankWithEmptyString() {
		assertTrue(JU.string.isBlank(''));
	}
	
	/*
	 * Tests isDigits() with an empty string parameter
	 */
	function testIsDigitsWithEmptyString() {
		assertFalse(JU.string.isDigits(''));
	}
	
	/*
	 * Tests isInteger() with an empty string parameter
	 */
	function testIsIntegerWithEmptyString() {
		assertFalse(JU.string.isInteger(''));
	}
	
	/*
	 * Tests isDecimal() with an empty string parameter
	 */
	function testIsDecimalWithEmptyString() {
		assertFalse(JU.string.isDecimal(''));
	}
	
	/*
	 * Tests isDate() with empty string parameters
	 */
	function testIsDecimalWithEmptyString() {
		assertFalse(JU.string.isDate('', ''));
	}
	
	/*
	 * Tests isEmail() with an empty string parameter
	 */
	function testIsEmailWithEmptyString() {
		assertFalse(JU.string.isEmail(''));
	}
	
	/*
	 * Tests trim() with an empty string parameter
	 */
	function testTrimWithEmptyString() {
		assertEquals('', JU.string.trim(''));
	}
	
	//--------------------------------------------------------------------------
	// Tests with correct parameters
	//--------------------------------------------------------------------------
	
	/*
	 * Tests isEmpty() with an expected input
	 */
	function testIsEmpty() {
		assertTrue(JU.string.isEmpty(''));
	}
	
	/*
	 * Tests isBlank() with an expected input
	 */
	function testIsBlank() {
		assertTrue(JU.string.isBlank('      '));
	}
	
	/*
	 * Tests isDigits() with an expected input
	 */
	function testIsDigits() {
		assertTrue(JU.string.isDigits('0123456789'));
	}
	
	/*
	 * Tests isInteger() with an positive integer
	 */
	function testIsIntegerPositive() {
		assertTrue(JU.string.isInteger('123456789'));
	}
	
	/*
	 * Tests isInteger() with a negative integer
	 */
	function testIsIntegerNegative() {
		assertTrue(JU.string.isInteger('-123456789'));
	}
	
	/*
	 * Tests isInteger() with an positive integer starting with zero
	 */
	function testIsIntegerPositiveStartingWithZero() {
		assertTrue(JU.string.isInteger('0123456789'));
	}
	
	/*
	 * Tests isInteger() with a negative integer starting with zero
	 */
	function testIsIntegerNegativeStartingWithZero() {
		assertTrue(JU.string.isInteger('-0123456789'));
	}
	
	/*
	 * Tests isInteger() with a zero
	 */
	function testIsIntegerZero() {
		assertTrue(JU.string.isInteger('0'));
	}
	
	/*
	 * Tests isInteger() with zeroes
	 */
	function testIsIntegerZeroes() {
		assertTrue(JU.string.isInteger('000000000'));
	}
	
	/*
	 * Tests isInteger() with a minus zero
	 */
	function testIsIntegerWithMinusZero() {
		assertTrue(JU.string.isInteger('-0'));
	}
	
	/*
	 * Tests isInteger() with a minus zero
	 */
	function testIsIntegerWithMinusZeroes() {
		assertTrue(JU.string.isInteger('-00000000'));
	}
	
	/*
	 * Tests isDecimal() with a positive number
	 */
	function testIsDecimalPositive() {
		assertTrue(JU.string.isDecimal('1234.56789'));
	}
	
	/*
	 * Tests isDecimal() with a negative number
	 */
	function testIsDecimalNegative() {
		assertTrue(JU.string.isDecimal('-1234.56789'));
	}
	
	/*
	 * Tests isDecimal() with a positive integer starting with zero
	 */
	function testIsDecimalPositiveStartingWithZero() {
		assertTrue(JU.string.isDecimal('01234.56789'));
	}
	
	/*
	 * Tests isDecimal() with a negative integer starting with zero
	 */
	function testIsDecimalNegativeStartingWithZero() {
		assertTrue(JU.string.isDecimal('-01234.56789'));
	}
	
	/*
	 * Tests isDecimal() with a positive integer
	 */
	function testIsDecimalWithPositiveInteger() {
		assertTrue(JU.string.isDecimal('123456789'));
	}
	
	/*
	 * Tests isDecimal() with a negative integer
	 */
	function testIsDecimalWithNegativeInteger() {
		assertTrue(JU.string.isDecimal('-123456789'));
	}
	
	/*
	 * Tests isDecimal() with a positive integer starting with zero
	 */
	function testIsDecimalWithPositiveIntegerStartingWithZero() {
		assertTrue(JU.string.isDecimal('0123456789'));
	}
	
	/*
	 * Tests isDecimal() with a negative integer starting with zero
	 */
	function testIsDecimalWithNegativeIntegerStartingWithZero() {
		assertTrue(JU.string.isDecimal('-0123456789'));
	}
	
	/*
	 * Tests isDecimal() with a zero
	 */
	function testIsDecimalZero() {
		assertTrue(JU.string.isDecimal('0'));
	}
	
	/*
	 * Tests isDecimal() with zeroes
	 */
	function testIsDecimalZeroes() {
		assertTrue(JU.string.isDecimal('000000000'));
	}
	
	/*
	 * Tests isDecimal() with a minus zero
	 */
	function testIsDecimalWithMinusZero() {
		assertTrue(JU.string.isDecimal('-0'));
	}
	
	/*
	 * Tests isDecimal() with a minus zero
	 */
	function testIsDecimalWithMinusZeroes() {
		assertTrue(JU.string.isDecimal('-00000000'));
	}
	
	/*
	 * Tests isDecimal() with a minus zero point zero
	 */
	function testIsDecimalWithMinusZeroPointZero() {
		assertTrue(JU.string.isDecimal('-0.0'));
	}
	
	/*
	 * Tests isDecimal() with a minus zeroes point zero
	 */
	function testIsDecimalWithMinusZeroes() {
		assertTrue(JU.string.isDecimal('-00000000.0'));
	}
	
	/*
	 * Tests isDate() with a valid date in dd/MM/yyyy format
	 */
	function testIsDate() {
		assertTrue(JU.string.isDate('20/03/1982', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a valid date in MM/dd/yyyy format
	 */
	function testIsDateMMddyyyy() {
		assertTrue(JU.string.isDate('03/20/1982', 'MM/dd/yyyy'));
	}
	
	/*
	 * Tests isDate() with a valid date in yyyy/MM/dd format
	 */
	function testIsDateyyyyMMdd() {
		assertTrue(JU.string.isDate('1982/03/20', 'yyyy/MM/dd'));
	}
	
	/*
	 * Tests isDate() with a valid date in yyyy/dd/MM format
	 */
	function testIsDateyyyyddMM() {
		assertTrue(JU.string.isDate('1982/20/03', 'yyyy/dd/MM'));
	}
	
	/*
	 * Tests isEmail() with a valid email
	 */
	function testIsEmail() {
		assertTrue(JU.string.isEmail('janutils@gmail.com'));
	}
	
	/*
	 * Tests isEmail() with a valid email that contains different sepparators
	 */
	function testIsEmailWithSeparators() {
		assertTrue(JU.string.isEmail('janutil.js-0.1_beta@my.test.com'));
	}
	
	/*
	 * Tests trim() with a string with spaces in both sides
	 */
	function testTrim() {
		assertEquals('JanUtils', JU.string.trim('    JanUtils   '));
	}
	
	/*
	 * Tests trim() with a string with a blank string
	 */
	function testTrimSpaces() {
		assertEquals('', JU.string.trim('       '));
	}
	
	/*
	 * Tests trim() with a string with spaces to the left
	 */
	function testTrimSpacesLeft() {
		assertEquals('JanUtils', JU.string.trim('    JanUtils'));
	}
	
	/*
	 * Tests trim() with a string with spaces to the left
	 */
	function testTrimSpacesRight() {
		assertEquals('JanUtils', JU.string.trim('JanUtils    '));
	}

	//--------------------------------------------------------------------------
	// Tests with incorrect parameters
	//--------------------------------------------------------------------------
	
	/*
	 * Tests isEmpty() with an space
	 */
	function testIsEmptyWithSpace() {
		assertFalse(JU.string.isEmpty(' '));
	}
	
	/*
	 * Tests isEmpty() with an alphabetic parameter
	 */
	function testIsEmptyWithAlpha() {
		assertFalse(JU.string.isEmpty('JanUtils'));
	}
	
	/*
	 * Tests isBlank() with an alphabetic parameter
	 */
	function testIsBlankWithAlpha() {
		assertFalse(JU.string.isBlank('JanUtils'));
	}
	
	/*
	 * Tests isBlank() with an string that starts with a space
	 */
	function testIsBlankWithStartSpace() {
		assertFalse(JU.string.isBlank(' a'));
	}
	
	/*
	 * Tests isBlank() with an string that finishes with a space
	 */
	function testIsBlankWithFinishSpace() {
		assertFalse(JU.string.isBlank('a '));
	}
	
	/*
	 * Tests isInteger() with an alphabetic parameter
	 */
	function testIsIntegerWithAlpha() {
		assertFalse(JU.string.isInteger('JanUtils'));
	}
	
	/*
	 * Tests isInteger() with a minus sign
	 */
	function testIsIntegerWithMinus() {
		assertFalse(JU.string.isInteger('-'));
	}
	
	/*
	 * Tests isInteger() with a double minus sign
	 */
	function testIsIntegerWithDoubleMinus() {
		assertFalse(JU.string.isInteger('--'));
	}
	
	/*
	 * Tests isDecimal() with an alphabetic parameter
	 */
	function testIsDecimalWithAlpha() {
		assertFalse(JU.string.isDecimal('JanUtils'));
	}
	
	/*
	 * Tests isDecimal() with a minus sign
	 */
	function testIsDecimalWithMinus() {
		assertFalse(JU.string.isDecimal('-'));
	}
	
	/*
	 * Tests isDecimal() with a double minus sign
	 */
	function testIsDecimalWithDoubleMinus() {
		assertFalse(JU.string.isDecimal('--'));
	}
	
	/*
	 * Tests isDigits() with an alphabetic parameter
	 */
	function testIsDigitsWithAlpha() {
		assertFalse(JU.string.isDigits('JanUtils'));
	}
	
	/*
	 * Tests isDigits() with an string that starts with a space
	 */
	function testIsDigitsWithStartSpace() {
		assertFalse(JU.string.isDigits(' 9'));
	}
	
	/*
	 * Tests isDigits() with an string that finishes with a space
	 */
	function testIsDigitsWithFinishSpace() {
		assertFalse(JU.string.isDigits('9 '));
	}
	
	/*
	 * Tests isDigits() with an string that starts with a space
	 */
	function testIsDigitsWithStartSpace() {
		assertFalse(JU.string.isDigits(' 9'));
	}
	
	/*
	 * Tests isDigits() with an string that finishes with a space
	 */
	function testIsDigitsWithFinishSpace() {
		assertFalse(JU.string.isDigits('9 '));
	}
	
	/*
	 * Tests isDate() with an space and a valid format
	 */
	function testIsDateWithSpace() {
		assertFalse(JU.string.isDate(' ', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with an alphabetic string and a valid format
	 */
	function testIsDateWithAlpha() {
		assertFalse(JU.string.isDate('abcdef', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a numric string and a valid format
	 */
	function testIsDateWithNumbers() {
		assertFalse(JU.string.isDate('12345', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a date string that starts with a space and a valid format
	 */
	function testIsDateWithStartSpace() {
		assertFalse(JU.string.isDate(' 20/03/1982', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a date string that finishes with a space and a valid format
	 */
	function testIsDateWithFinishSpace() {
		assertFalse(JU.string.isDate('20/03/1982 ', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with an invalid date and a valid format
	 */
	function testIsDateInvalid() {
		assertFalse(JU.string.isDate('03/20/1982', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with february 29 in a no leap year and a valid format
	 */
	function testIsDateInvalidNoLeap() {
		assertFalse(JU.string.isDate('29/02/2009', 'dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a valid date and spaces as format
	 */
	function testIsDateWithSpaceFormat() {
		assertFalse(JU.string.isDate('20/03/1982', '   '));
	}
	
	/*
	 * Tests isDate() with a valid date and an alphabetic format
	 */
	function testIsDateWithAlphaFormat() {
		assertFalse(JU.string.isDate('20/03/1982', 'abcdef'));
	}
	
	/*
	 * Tests isDate() with a valid date and a numeric format
	 */
	function testIsDateWithNumbersFormat() {
		assertFalse(JU.string.isDate('20/03/1982', '1234567'));
	}
	
	/*
	 * Tests isDate() with a valid date and a format that starts with a space
	 */
	function testIsDateWithStartSpaceFormat() {
		assertFalse(JU.string.isDate('20/03/1982', ' dd/MM/yyyy'));
	}
	
	/*
	 * Tests isDate() with a valid date and a format that finishes with a space
	 */
	function testIsDateWithFinishSpaceFormat() {
		assertFalse(JU.string.isDate('20/03/1982', 'dd/MM/yyyy '));
	}
	
	/*
	 * Tests isDate() with a format that repeats the day part
	 */
	function testIsDateWithRepeatedFormat() {
		assertFalse(JU.string.isDate('20/03/1982', 'dd/dd/yyyy'));
	}
	
	/*
	 * Tests isEmail() with an space
	 */
	function testIsEmailWithSpace() {
		assertFalse(JU.string.isEmail(' '));
	}
	
	/*
	 * Tests isEmail() with an alphabetic parameter
	 */
	function testIsEmailWithAlpha() {
		assertFalse(JU.string.isEmail('JanUtils'));
	}
	
	/*
	 * Tests isEmail() with a numeric parameter
	 */
	function testIsEmailWithNumbers() {
		assertFalse(JU.string.isEmail('1234567890'));
	}
	
	/*
	 * Tests isEmail() with a email without the left part
	 */
	function testIsEmailWithoutLeft() {
		assertFalse(JU.string.isEmail('@gmail.com'));
	}
	
	/*
	 * Tests isEmail() with a email without the right part
	 */
	function testIsEmailWithoutRight() {
		assertFalse(JU.string.isEmail('JanUtils'));
	}
	
	/*
	 * Tests isEmail() with a email with spaces to the left
	 */
	function testIsEmailWithSpacesLeft() {
		assertFalse(JU.string.isEmail(' janutils@gmail.com'));
	}
	
	/*
	 * Tests isEmail() with a email with spaces to the right
	 */
	function testIsEmailWithSpacesRight() {
		assertFalse(JU.string.isEmail('janutils@gmail.com '));
	}
	
	</script>
</head>
<body>
</body>
</html>